home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group96a.txt
/
000092_icon-group-sender _Wed Apr 17 16:19:37 1996.msg
< prev
next >
Wrap
Internet Message Format
|
1996-09-05
|
2KB
Received: by cheltenham.cs.arizona.edu; Wed, 17 Apr 1996 17:19:38 MST
Date: Wed, 17 Apr 1996 16:19:37 -0500
Message-Id: <199604172119.QAA18647@post.its.mcw.edu>
X-Sender: cdt@post.its.mcw.edu
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: Hamish Lawson <H.Lawson@tees.ac.uk>
From: cdt@post.its.mcw.edu (Chris D. Tenaglia)
Subject: Re: Splitting and joining strings
Cc: icon-group@cs.arizona.edu
X-Mailer: <PC Eudora Version 1.4>
Errors-To: icon-group-errors@cs.arizona.edu
Status: O
I have a routine called "parse" I thought was in the IPL. It looks
something like:
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
The delimiter is a cset in this case allowing a little more
tokenizing flexibility. The join thing can be done in one or
two expressions like:
text := ""
every text ||:= !items || ":"
If you don't mind the trailing delimiter.
Chris.
>Before I rolled my own I thought I'd have a look in the Icon Program
Library for a
>couple of procedures I need.
>
>The first should split a string on a specified separator, along the lines of
>
> split("Joe:Sue:Bob:Ann", ":") produces "Joe", "Sue", "Bob", "Ann"
>
>The second should join the elements of a list into a string, with each element
>separated by a specified separator, along the lines of:
>
> join(["Joe", "Sue", "Bob", "Ann"], ":") produces "Joe:Sue:Bob:Ann"
>
>I couldn't find any such procedures in the IPL. Have I missed them?
>
>
>| Hamish Lawson, School of Computing and Mathematics,
>| University of Teesside, Middlesbrough, Cleveland, UK, TS1 3BA
>| Tel: +44 1642 212695 Fax: +44 1642 342604
>| E-mail: H.Lawson@tees.ac.uk
>
>
Chris Tenaglia (system manager) | cdt@post.its.mcw.edu
Medical College of Wisconsin |
8701 W. Watertown Plank Rd. | Ce que vous voyez est
Milwaukee, WI 53226 (414)456-8765 | Ce que vous obtenez !